package com.sjb.stock.controller;

import com.sjb.stock.pojo.entity.SysUser;
import com.sjb.stock.service.impl.userServiceImpl;
import com.sjb.stock.vo.req.LoginReqVo;
import com.sjb.stock.vo.resp.LoginRespVo;
import com.sjb.stock.vo.resp.R;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;


/**
 * @FileName userController
 * @Description 
 * @Author chm
 * @date 2025/6/21
 **/
@RestController
@RequestMapping("/api")
public class userController {
    @Resource
    private userServiceImpl userServiceImpl;

    /**
     * @description: 查找系统用户信息
     * @param useName
     * @return com.sjb.stock.pojo.entity.SysUser
     * @author chm
     * @date 2025/7/15
     **/
    @RequestMapping("/user/{useName}")
    public SysUser getUserByUserName(@PathVariable("useName") String useName) {
        return userServiceImpl.getUserByUserName(useName);
    }
    /**
     * @description: 登录功能
     * @param loginReqVo
     * @return com.sjb.stock.vo.resp.R<com.sjb.stock.vo.resp.LoginRespVo>
     * @author chm
     * @date 2025/7/15
     **/
    @PostMapping("/login")
    public R<LoginRespVo> login(@RequestBody LoginReqVo loginReqVo) {
        return userServiceImpl.login(loginReqVo);
    }

    /**
     * @description: 生成图片验证码
     * @return com.sjb.stock.vo.resp.R<java.util.Map>
     * @author chm
     * @date 2025/7/15
     **/
    @GetMapping("/captcha")
    public R<Map> getCaptchaCode() {  return userServiceImpl.getCaptchaCode(); }

}
